<?php
/**
 * Implements a MySQL UPDATE query
 */
class MySQLUpdate extends SQLUpdate {
	private $objOptions;
	private $objJoins;
	
	/**
	 * Sets options clause for query.
	 *
	 * @param SQLOptionsClause $objSQLOptions
	 * @return MySQLDelete
	 */
	public function setOptions($objSQLOptions) {
		$this->objOptions = $objSQLOptions;
		return $this;
	}
	
	/**
	 * Sets JOIN clauses for query.
	 * 
	 * @param SQLJoinsClause $objSQLJoins
	 * @return MySQLDelete
	 */
	public function setJoins($objSQLJoins) {
		$this->objJoins = $objSQLJoins;
		return $this;
	}
	
	/**
	 * Outputs query as string.
	 * 
	 * (non-PHPdoc)
	 * @see SQLDelete::toString()
	 */
	public function toString() {
		return "".
		"UPDATE ".($this->objOptions?$this->objOptions->toString():"")." ".$this->strTableName	."\r\n".
		($this->objJoins?$this->objJoins->toString():"")										."\r\n".
		"SET ".$this->objUpdates->toString()													."\r\n".
		"WHERE ".($this->objConditions?$this->objConditions->toString():"1");
	}
}